home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / cg / savetextfile.rexx < prev    next >
OS/2 REXX Batch file  |  1995-12-28  |  1KB  |  58 lines

  1. /* SaveTextFile.rexx -- Saves a page as an Ascii File. */
  2. /* By Bob Caron © 1994 NewTek, Inc.                    */
  3.  
  4. call addlib(CG_AREXX,0)
  5.  
  6. filnam = 'ENV:SaveTextFile.state'
  7. version = 'SaveTextFile v1.4'
  8.  
  9. if (exists(filnam)) then do
  10.     if (~open(state, filnam, 'R')) then break
  11.     if (readln(state) ~= version) then break
  12.     file=readln(state)
  13.     end
  14.     call close state
  15.  
  16. if file="" | file="FILE" then
  17.    file="toaster:CG/TextFiles/Page.txt"
  18. if lastpos('/',file,length(file)-1)~=0 then do
  19.    filenam=right(file,(length(file)-lastpos('/',file,length(file)-1)))
  20.    path=left(file,(lastpos('/',file,length(file))-1))
  21.    end
  22. else do
  23.    filenam=right(file,(length(file)-lastpos(':',file,length(file)-1)))
  24.    path=left(file,(lastpos(':',file,length(file))))
  25.    end
  26.  
  27. outfile=REQ_FILE("Save To Ascii File",filenam,path)
  28.  
  29. file=script
  30. if (open(state, filnam, 'W')) then do
  31.     call writeln state, version
  32.     call writeln state, file
  33.     call close state
  34. end
  35.  
  36. if outfile="" then
  37.    exit
  38.  
  39. if (~open(outfd,outfile,W)) then do
  40.      call REQ_TELL("Can't open output:",file)
  41.      exit
  42.      end
  43.  
  44. current_line=1
  45. total_lines=GET_PAGE(SIZE)
  46.  
  47. do while current_line <= total_lines
  48.    call SET_LINE(current_line)
  49.    line=GET_LINE()
  50.    writeln(outfd,line)
  51.    current_line=current_line+1
  52.    end
  53.    call close(outfd)
  54.    call REQ_TELL("Saved...")
  55. call remlib(CG_AREXX)
  56. exit
  57.  
  58.